import axios from 'axios'
import qs from 'qs'

import { getDomain } from './domain'

export function post(url, body) {
  return axios.post(getDomain() + url, qs.stringify(body), {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }).then(data=>{
    if (data.code === '0000') {
      return data.data
    } else {
      return Promise.reject({ code: data.code, message: data.message })
    }
  })
}